package gouhuo.allbugs.top.utils;

import java.time.LocalDate;

import static gouhuo.allbugs.top.constant.RedisConstants.CHAT_LIST_KEY;

/**
 * 生成聊天记录key的工具类
 */
public class ChatKeyUtil {

    static String now;

    static {
        LocalDate date = LocalDate.now();
        now = ":" + date.getYear() + "-" + date.getMonthValue() + ":day" + date.getDayOfMonth();
    }

    public static String getPriKey(Long toId, Long fromId) {
        long min = Math.min(toId, fromId);
        long max = Math.max(toId, fromId);
        return CHAT_LIST_KEY + now + ":user:" + min + "&&" + max;
    }

    public static String getTeamKey(Long teamId) {
        return CHAT_LIST_KEY + now + ":team:" + teamId;
    }

}
